#include"head.h"

int login(request_t * req, response_t * res, char * login_info[], int net_fd){

    // 拼接登录报文
    req->flag = LOGIN;
    strcpy(req->user_name, login_info[2]);

    // 报文的arsg传md5
    char * password = login_info[4];
    char md5_password[MD5_STRING_LENGTH];
    compute_md5_hash(password, md5_password);
    strcpy(req->args, md5_password);

    // 发送login报文
    int ret = send(net_fd, req, sizeof(request_t), 0);
    // 等待响应报文
    recv(net_fd, res, sizeof(response_t), 0);
    if (res->status == 1)
    {
        // 服务端通知登录异常
        return 1;
    }

    return 0;

}
